﻿import QtQuick 2.0
import "../components"

Item {
    id: root

    anchors.fill: parent

    property int guidePage: 0
    property int filterPage: 0

    property int type: 0

    onVisibleChanged: {
        if(visible){
            refresh(type)
        }
    }

    function refresh(type){
        if(type === 0){
            table1.setData(CAnalysis.getGuideTable1())
            table2.setData(CAnalysis.getGuideTable2())
            text_AL.text = (CAnalysis.getGuideLabel("AL"))
            text_AS.text = (CAnalysis.getGuideLabel("AS"))
            text_Y.text = (CAnalysis.getGuideLabel("Y"))
            bt1.title="全部:"+CAnalysis.getNum()[0];
            bt2.title="常STR:"+CAnalysis.getNum()[1];
            bt3.title="mini-STR:"+CAnalysis.getNum()[3];
            bt4.title="Y-STR:"+CAnalysis.getNum()[2];
            bt5.title="需稀释样本数:"+CAnalysis.getNum()[4];
        }else{
            // 打开其它设备
            table1.setData(CULF.getGuideTable1())
            table2.setData(CULF.getGuideTable2("全部"))
            bt1.title="全部:"+CULF.typeNum()[0];
            bt2.title="常STR:"+CULF.typeNum()[1];
            bt3.title="mini-STR:"+CULF.typeNum()[3];
            bt4.title="Y-STR:"+CULF.typeNum()[2];
            bt5.title="需稀释样本数:"+CULF.typeNum()[4];
        }

    }

    onFilterPageChanged: {
        if(type === 0){
            if(filterPage === 0){
                table2.setData(CAnalysis.getGuideTable2("全部"));
            }if(filterPage === 1){
                table2.setData(CAnalysis.getGuideTable2("常STR"));
            }if(filterPage === 2){
                table2.setData(CAnalysis.getGuideTable2("mini-STR"));
            }if(filterPage === 3){
                table2.setData(CAnalysis.getGuideTable2("Y-STR"));
            }if(filterPage === 4){
                table2.setData(CAnalysis.getGuideTable2("需稀释样本"));
            }
        }else{
            if(filterPage === 0){
                table2.setData(CULF.getGuideTable2("全部"));
            }if(filterPage === 1){
                table2.setData(CULF.getGuideTable2("常STR"));
            }if(filterPage === 2){
                table2.setData(CULF.getGuideTable2("mini-STR"));
            }if(filterPage === 3){
                table2.setData(CULF.getGuideTable2("Y-STR"));
            }if(filterPage === 4){
                table2.setData(CULF.getGuideTable2("需稀释样本"));
            }
        }


    }

    Item{           // 上面的行
        height: 40*dp
        PushButton{
            x: 10*dp
            y: 5*dp
            height: 30*dp
            width: 90*dp
            title: "分析数据"
            defaultMode2: true
            text_color: "#333333"
            button_color_select: "#222222"
            text_color_select: "white"
            isSelected: guidePage === 0
            onReleased: {
                guidePage = 0
            }
        }PushButton{
            x: 105*dp
            y: 5*dp
            height: 30*dp
            width: 90*dp
            title: "检测方案"
            defaultMode2: true
            text_color: "#333333"
            button_color_select: "#222222"
            text_color_select: "white"
            isSelected: guidePage === 1
            onReleased: {
                guidePage = 1
            }
        }

        Item{
            height: 30*dp
            width: 500*dp
            x: root.width - 500*dp
            y: 5*dp
            PushButton{
                id : bt1
                height: 30*dp
                width: 80*dp
                title: "全部"
                text_color_select: "#1677FF"
                isSelected: filterPage === 0
                onReleased: {
                    filterPage = 0
                }
            }PushButton{
                id : bt2
                height: 30*dp
                width: 80*dp
                x: 90*dp
                title: "常STR"
                text_color_select: "#1677FF"
                isSelected: filterPage === 1
                onReleased: {
                    filterPage = 1
                }
            }PushButton{
                id : bt3
                height: 30*dp
                width: 80*dp
                x: 180*dp
                title: "mini-STR"
                text_color_select: "#1677FF"
                isSelected: filterPage === 2
                onReleased: {
                    filterPage = 2
                }
            }PushButton{
                id : bt4
                height: 30*dp
                width: 80*dp
                x: 270*dp
                title: "Y-STR"
                text_color_select: "#1677FF"
                isSelected: filterPage === 3
                onReleased: {
                    filterPage = 3
                }
            }PushButton{
                id : bt5
                height: 30*dp
                width: 120*dp
                x: 360*dp
                title: "需稀释样本数"
                text_color_select: "#1677FF"
                isSelected: filterPage === 4
                onReleased: {
                    filterPage = 4
                }
            }
            visible: guidePage === 1

        }


    }


    Item{           // 表格
        height: root.height - 100*dp
        width: root.width
        y: 40*dp
        CustomTable{
            id: table1
            title: ["序号", "孔位", "样本名称", "样本类型", "荧光染料", "CT值", "样本浓度<br/>ng/μl", "总浓度<br/>ng/μl", "男性浓度<br/>ng/μl", "女性浓度<br/>ng/μl", "性别情况", "男女浓度比例<br/>ng/μl", "降解指数DI", "抑制指数ICS"]
            visible: guidePage === 0
        }
        CustomTable{
            id: table2
            title: ["序号", "孔位", "样本名称", "检测方案", "总稀释倍数", "", "第一步稀释", "", "", "第二步稀释步骤", "", "扩增上样体积", "备注"]
            title2: ["", "", "", "", "", "稀释倍数1", "样品体积", "稀释液体积", "稀释倍数2", "上一步稀释产物", "稀释液体积", "", "", ]
            doubleTitle: true
            visible: guidePage === 1
        }

    }

//    Item{
//        y: 100*dp
//        height: 50*dp
//        width: root.width
//        Text{
//            anchors.fill: parent
//            text: "原始数据不完整，无法计算下游操作建议"
//        }
//    }

    Item{           // 下面的显示
        id : val1
        height: 50*dp
        y: root.height - 50*dp
        width: root.width - 10*dp
        x: 10*dp
        visible: type === 0
        Text {
            id: text_AL
            color: config.colorChannel1
            font.pixelSize: config.fontsize
            text: "text"
            height: 30*dp
            verticalAlignment: Text.AlignVCenter
        }Text{
            id: text_Y
            color: config.colorChannel2
            font.pixelSize: config.fontsize
            text: "text"
            x: parent.width / 2
            height: 30*dp
            verticalAlignment: Text.AlignVCenter
        }Text{
            id: text_AS
            color: config.colorChannel3
            font.pixelSize: config.fontsize
            text: "text"
            y: 30*dp
            height: 30*dp
            verticalAlignment: Text.AlignVCenter
        }
    }

    MaskInfo{
        anchors.centerIn: parent
        title: "当前数据无法计算指导建议"
        visible: curPage === 3 && (!canGuide || !canAnalysis)
        anchors.verticalCenterOffset: -20*dp
    }

}
